<?php
namespace app\superadmin\controller;
use app\superadmin\model\Index as IndexModel;
//继承Base控制器
class Restaurant extends Base
{
   public function dininglist()
    {
       $diningres= \think\Db::name('dining')
             ->alias('a')
             ->join('__SHOPADMINS__ b', 'a.admin_id =b.id')
             ->field('a.shop_id,a.shopname,a.level,a.phonenum,a.address,a.state,a.shoptime,a.service,a.intro,b.adminname,a.pic')
             ->where('a.admin_id =b.id')
             ->paginate(4);
             //var_dump($diningres);die;
       $this->assign('diningres',$diningres);
      return $this->fetch();
    }
    

    public function deldining(){
      $shop_id=input('shop_id');
      if(db('dining')->delete($shop_id)){
        return $this->success('删除成功！','dininglist');
      }else{
        return $this->error('删除成功！','dininglist');
      }
    }


    public function changediningstate(){
      $shop_id=input('shop_id');//获取id
      if($db=\think\Db::name('dining')->where('shop_id',$shop_id)->update(['state' =>input('state')])){
         //return $this->success('餐厅状态重置成功！','dininglist');
         return $this->redirect('dininglist');
      }else{
         return $this->error('餐厅状态状态重置失败！','dininglist');
      }
       return;
    } 

   
}
